<!DOCTYPE html>
<html lang="en">
<head>
    <base href="../../">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/layui.css">
    <title>创建文本域</title>
</head>
<body>
    <div class="layui-form">
        <div class="layui-form-item">
            <label class="layui-form-label">标签名</label>
            <div class="layui-input-block">
                <input type="text" name="name" id="name" lay-verify="required" lay-reqtext="文本域标签不能为空" placeholder="请输入文本域标签" value="" class="layui-input">
                <tip>文本域左侧显示的文字</tip>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文本域样式</label>
            <div class="layui-input-block">
                <select name="size" id="size">
                    <option value="inline" checked>短</option>
                    <option value="block">长</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否必填</label>
            <div class="layui-input-block">
                <input type="checkbox" name="isRequired" id="isRequired"  value="true" lay-skin="switch" lay-text="必填|不必">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">占位文本</label>
            <div class="layui-input-block">
                <input type="text" name="placeholder" id="placeholder"  placeholder="请输入占位文本" value="" class="layui-input">
                <tip>无内容时显示的文本</tip>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">创建</button>
            </div>
        </div>
    </div>

    <script src="layui.js"></script>
    <script>
        layui.use('form',function(){
            var form = layui.form;

            //监听提交
            form.on('submit(saveBtn)', function (data) {
                console.log("data",data,data.field);
                parent.layui.data("form_data",{
                    key: "carry",
                    // value: JSON.stringify(data.field)
                    value: data.field
                });
                
                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);
            });
        });
    </script>
</body>
</html>